#!python
# (C) Copyright 2016-2021 Intel Corporation.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
"""Build self test"""

import os
import daos_build

SELF_TEST = 'self_test.c'

def scons():
    """scons function"""

    Import('env', 'prereqs', 'cart_lib', 'gurt_lib', 'cart_utils_objs')

    tenv = env.Clone(LIBS=[])

    tenv.AppendUnique(LIBS=['cart', 'gurt', 'pthread', 'm', 'daos', 'daos_common'])
    prereqs.require(tenv, 'mercury', 'protobufc')
    tenv.AppendUnique(FLAGS='-pthread')

    self_test = daos_build.program(tenv, [SELF_TEST, cart_utils_objs])
    tenv.Requires(self_test, [cart_lib, gurt_lib])
    tenv.Install(os.path.join("$PREFIX", 'bin'), self_test)

if __name__ == "SCons.Script":
    scons()
